import React, {Component} from "react";
import {View} from "@tarojs/components";
import Ltabs from "../../components/common/Ltabs";
import PiGai from "./piGai";
import Dianming from "./dianming";
import Zhuoye from "./zhuoye";
import Lishi from "./lishi";
import Zongjie from "./zongjie";
import Banwu from "./banwu";
import DynamicComponent from "../../components/common/DynamicComponent";
import './css.scss'

const DuiHuaKuang = React.$DuiHuaKuang
class ClassManage extends Component {
  constructor(props) {
    super(props);
    this.state = {
      ltabsList: [
        {
          name: '点名',
          component: Dianming
        },
        {
          name: '作业',
          component: Zhuoye
        },
        {
          name: '批改',
          active: true,
          component: PiGai
        },
        {
          name: '总结',
          component: Zongjie
        },
        {
          name: '历史',
          component: Lishi
        },
        {
          name: '班务',
          component: Banwu
        }
      ],
      curComponent: '批改'
    }
  }
  _DuiHuaKuangRef = null
  getDuiHuaKuangRef = (e)=> {
    this._DuiHuaKuangRef = e
    console.log('this', this)
  }
  // showDhK = function (e) {
  //   const {}
  // }
  clickLtabs = (e) => {
    console.log('e', e)
    this.setState({curComponent: e.name})
  }
  render() {
    const { ltabsList, curComponent } = this.state
    return (
      <View className='classManage-box'>
        <View className='top ltabs'>
          <Ltabs ltabsList={ltabsList} clickLtabs={this.clickLtabs} />
        </View>
        <View className='bottom'>
          {
            // curComponent === '批改' ?  <PiGai _DuiHuaKuangRef={this._DuiHuaKuangRef} /> :
            //   <Dianming className='tyhezibox' />
          }
          <DynamicComponent component={(ltabsList.find(item => item.name === curComponent)).component} />

        </View>
        <DuiHuaKuang getDuiHuaKuangRef={this.getDuiHuaKuangRef} />
      </View>
    )
  }
}
export default ClassManage
